// 对于sessionStorage定义
class Store {

  get(key) {
    let value = sessionStorage.getItem(key) || ''
    if (value.includes('[') || value.includes('{')) { // 对象
      return JSON.parse(value)
    }
    return value
  }

  set(key, value) {
    if (typeof value == 'object') value = JSON.stringify(value)
    sessionStorage.setItem(key, value)
  }

  has(key) {
    return this.get(key) ? true : false
  }

  remove(key) {
    sessionStorage.removeItem(key)
  }

}

export default new Store;